/**
 * 防抖函数
 * @param callback 回调
 * @param time 防抖有效时间
 * @returns 
 */
export const debounce = (callback: Function, time: number) => {
  let timeout: number | undefined
  return (...params: any) => {
    clearTimeout(timeout)
    timeout = setTimeout(() => {
      timeout = undefined
      callback(params)
    }, time)
  }
}

/**
 * 转大驼峰
 * @param str 字符串
 * @returns 
 */
export const toCamelCase = (str: string) => {
  return str.replace(/(?:^|-)([a-z])/g, (_, match) => match.toUpperCase())
}
